<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../common/admin.asp"-->
<%
key=request.QueryString("key")
mark=request.QueryString("mark")
uid=request.QueryString("uid")
pay=request.QueryString("pay")
search=request.QueryString("search")
if search="搜索" then
	  if key<>"" then
			sqlsearch=" and [order]='"&key&"'"
	  end if
	  if uid<>"" then
			sqlsearch=sqlsearch+" and uid='"&uid&"'"
	  end if
end if
'分页-------------------------------------------------------
set Rs=server.CreateObject("ADODB.RecordSet")
sql="select count(sortid) from (Select ROW_NUMBER() OVER (order by Addtime desc ) as sortid,* From OrderList) as TempTable where 1=1 and flag=0 "&sqlsearch&""
Pager_Pagesize=10 '每页记录数
Rs.open sql,conn,1,1
Pager_TotalRecord=Rs(0) '总记录数
Rs.close
Pager_PageCount=int((Pager_TotalRecord/Pager_Pagesize)+0.99999) '计算总页数
CurrentPage=Request("page") '当前页
'如果不为数字则直接设置页码为1
if isnumeric(CurrentPage)=False Or CurrentPage="" then
	CurrentPage=1
'如果当前页数大于总页数，则直接设置页码为1
elseif  Clng(CurrentPage)>Pager_PageCount then
	CurrentPage=1
end if
Fieldsname=" [Order],[Uid],[Money],[Promoney],adminname,[ServiceCost],[usedPoint],[Canlackpro],[Rate],[flag],[Addtime],sortid"
orderBy=" Order by sortid asc"
'拆分SQL语句，必须是select开头，有唯一标识的列
if instr("select",sql)<>-1 then
	if CurrentPage = 1 then
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize  & Fieldsname)
	else  
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize   & Fieldsname) & " and sortid >(select max(sortid) from (" & replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize * (CurrentPage - 1)  & Fieldsname) & orderBy & ") AA)"
	end if
end if
sql = sql & orderBy
Rs.open sql,conn,1,1
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>main</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
<style>body {background-color: #eaece1;}</style>
</head>

<body>
<div class="main">
  <div class="main-title">查看</div>
  <div class="main-content">
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <tr>
    <td colspan="6" align="center">
    <form name="form" method="get" action="">
    订单号<input name="key" type="text" id="key" value="<%=key%>" maxlength="50" />
     会员编号<input name="uid" type="text" id="uid" value="<%=uid%>" maxlength="50" />
    <input type="submit" name="search" value="搜索" />
    </form>
    </td>
    </tr>
    </table>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <form action="" method="post">
  <tr>
    <td align="center" bgcolor="#FFFFFF"><strong>选择</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong><span class="items">订单号</span></strong></td>
    <td align="center" bgcolor="#FFFFFF">更新者</td>
    <td align="center" bgcolor="#FFFFFF"><strong><span class="items">会员</span></strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>总金额</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>商品金额</strong></td>
    <td align="center" bgcolor="#FFFFFF">代购服务费</td>
    <td bgcolor="#FFFFFF"><strong>时间</strong></td>
    </tr>
    <%do while not Rs.eof%>
  <tr>
    <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="checkbox" id="checkbox" value="<%=rs("order")%>" <%if rs("flag")=true then response.Write " disabled "%>/></td>
    <td align="center" bgcolor="#FFFFFF"><a target="_blank" href="add.asp?id=<%=rs("order")%>"><%=rs("order")%></a></td>
    <td align="center" bgcolor="#FFFFFF"><%=rs("adminname")%></td>
    <td align="center" bgcolor="#FFFFFF">
	<a target="_blank" href="../user/edit.asp?id=<%=rs("uid")%>"><%set rss=conn.execute("select username from [user] where uid='"&rs("uid")&"'")
										   if not rss.eof then
										   response.write rss("username")
										   end if
										   set rss=nothing%></a>
    </td>
    <td align="center" bgcolor="#FFFFFF"><%=formatNumber(cdbl(rs("Promoney"))+cdbl(rs("ServiceCost")),2,-1)%>日元</td>
    <td align="center" bgcolor="#FFFFFF"><%=formatNumber(rs("Promoney"),2,-1)%>日元</td>
    <td align="center" bgcolor="#FFFFFF"><%=formatNumber(rs("ServiceCost"),2,-1)%>
      日元 <a href="?ServiceCostEdit=<%=rs("order")%>&ServiceCost=<%=formatNumber(rs("ServiceCost"),2,-1)%>">修改</a></td>
    <td bgcolor="#FFFFFF"><%=rs("addtime")%></td>
    </tr>
    <%
	Rs.movenext
	loop
	Rs.close
	Set Rs=nothing
	%>
    <tr>
      <td colspan="8" align="center" bgcolor="#FFFFFF" class="page">
<input type="submit" name="button" id="button" value="删除" />
      <input type="submit" name="button" id="button" value="已支付">  
      
      </td>
    </tr>
    </form>
    <tr>
    <td colspan="8" align="center" bgcolor="#FFFFFF" class="page">　
      <%
	siteurl=request.servervariables("document_name")
	%>
    <form action="<%=siteurl%>" method="get">
    共 <%=Pager_TotalRecord%> 条 第<%=CurrentPage%>页 / 共 <%=Pager_PageCount%> 页
		<%
		pageurl="key="&key&"&uid="&uid&"&pay="&pay&"&mark="&mark&"&search="&search&"&"
		if CurrentPage=1 then
			response.Write(" 首页 ")
			response.Write(" 上一页 ")
		else
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page=1'>首页</a> ")
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& (CurrentPage-1) &"'>上一页</a> ")
		end if
		%>
		<%
		if Clng(CurrentPage)=Clng(Pager_PageCount) then
			response.Write(" 下一页 ")
			response.Write(" 尾页 ")
		else
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& (CurrentPage+1) &"'>下一页</a> ")
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& Pager_PageCount &"'>尾页</a> ")
		end if
		%>
		&nbsp;
		<input name="page" type="text" value="<%=CurrentPage%>" size="1" maxlength="10" />
        <input type="submit" name="button" value="跳转" />
        <input type="hidden" name="key" value="<%=key%>" />
        <input type="hidden" name="uid" value="<%=uid%>" />
        <input type="hidden" name="mark" value="<%=mark%>" />
        <input type="hidden" name="pay" value="<%=pay%>" />
        <input type="hidden" name="search" value="搜索" />
        </form>
      </td>
    </tr>
  </table>
</div>
</div>












<%if request.QueryString("ServiceCostEdit")<>"" then%>
<div class="pop_contentx">
<h2><a href = "?page=<%=request.QueryString("page")%>">关闭</a>代购服务费修改</h2>
<ul>
  <table width="80%" border="0" cellspacing="0" cellpadding="4">
  <form name="formcn" method="post" action="" onSubmit="return myjobchk();">
    <tr>
      <td>订单号</td>
      <td><%=request.QueryString("ServiceCostEdit")%></td>
    </tr>
    <tr>
      <td>重量</td>
      <td><input name="ServiceCost" type="text" value="<%=request.QueryString("ServiceCost")%>" maxlength="10" />
        日元</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="r" id="button" value="保存" />
        <input type="hidden" name="t" value="ServiceCostEdit" />
        <input type="hidden" name="order" value="<%=request.QueryString("ServiceCostEdit")%>" />
        </td>
    </tr>
    </form>
  </table>
</ul>
</div> 
<div class="pop_bgx"></div> 
<%end if%>










</body>
</html>
<%
if request.Form("t")="ServiceCostEdit" then
 conn.execute("update OrderList set ServiceCost='"&request.Form("ServiceCost")&"',adminname='"&request.Cookies("admin")("name")&"' where [order]='"&request.Form("order")&"'")
 response.Redirect "?page="&request.QueryString("page")&""
end if



checkbox=request.Form("checkbox")
if checkbox<>"" then	
	if request.Form("button")="删除" then
		conn.execute("delete from Orderdetail where [order] in("&checkbox&")")
		conn.execute("delete from OrderList where [order] in("&checkbox&")")

	elseif request.Form("button")="已支付" then
		conn.execute("update OrderList set flag=1,adminname='"&request.Cookies("admin")("name")&"' where [order] in ("&checkbox&")")
		conn.execute("update orderdetail set mark=3 where [order] in ("&checkbox&")") 
	end if
	response.Redirect "notpayment.asp?page="&request.QueryString("page")&""
end if
%>